package org.jslaughter.event.eventtype;

import org.nvframe.entity.Entity;
import org.nvframe.event.AbstractEvent;
import org.nvframe.event.EventListener;

/**
 * 
 * @author Nik Van Looy
 */
public class DamageEvent extends AbstractEvent {

	private static Class<? extends EventListener> listener = DamageListener.class;
	public static enum DAMAGE_TYPE {
		EXPLOSION,
		BULLET,
		COLLISION
	}
	
	private Entity source;
	private Entity target;
	private int damagePoints;
	private DAMAGE_TYPE type;

	public DamageEvent(Entity source, Entity target, int damagePoints) {
		// set event-specific properties
		this.damagePoints = damagePoints;
		this.source = source;
		this.target = target;
	}
	
	public void dispatchToListener(EventListener listener) {
		((DamageListener) listener).damageReceived(this);
	}
	
	public DamageEvent(Entity source, Entity target, int damagePoints, DAMAGE_TYPE type) {
		this(source, target, damagePoints);
		this.type = type;
	}

	public Entity getSource() {
		return source;
	}
	
	public Entity getTarget() {
		return target;
	}

	public int getDamagePoints() {
		return damagePoints;
	}	

	public DAMAGE_TYPE getType() {
		return type;
	}

	public void setDamageType(DAMAGE_TYPE type) {
		this.type = type;
	}

	@Override
	protected Class<? extends EventListener> getListener() {
		return listener;
	}
}

